package com.equipmentRent.system.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.equipmentRent.system.domain.VO.LeaseRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.equipmentRent.system.mapper.LeaseRecordMapper;
import com.equipmentRent.system.domain.LeaseRecord;
import com.equipmentRent.system.service.ILeaseRecordService;
import com.equipmentRent.common.core.text.Convert;

/**
 * 租赁出库记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-28
 */
@Service
public class LeaseRecordServiceImpl extends ServiceImpl<LeaseRecordMapper,LeaseRecord> implements ILeaseRecordService

{
    @Autowired
    private LeaseRecordMapper leaseRecordMapper;

    /**
     * 查询租赁出库记录
     * 
     * @param id 租赁出库记录主键
     * @return 租赁出库记录
     */
    @Override
    public LeaseRecord selectLeaseRecordById(Long id)
    {
        return leaseRecordMapper.selectLeaseRecordById(id);
    }

    /**
     * 查询租赁出库记录列表
     * 
     * @param leaseRecord 租赁出库记录
     * @return 租赁出库记录
     */
    @Override
    public List<LeaseRecord> selectLeaseRecordList(LeaseRecord leaseRecord)
    {
        return leaseRecordMapper.selectLeaseRecordList(leaseRecord);
    }

    /**
     * 查询租赁出库记录列表
     * @param leaseRecord
     * @return
     */
    @Override
    public List<LeaseRecordVo> selectLeaseRecordVoList(LeaseRecord leaseRecord) {
        return leaseRecordMapper.selectLeaseRecordVoList(leaseRecord);
    }

    /**
     * 新增租赁出库记录
     * 
     * @param leaseRecord 租赁出库记录
     * @return 结果
     */
    @Override
    public int insertLeaseRecord(LeaseRecord leaseRecord)
    {
        return leaseRecordMapper.insertLeaseRecord(leaseRecord);
    }

    /**
     * 修改租赁出库记录
     * 
     * @param leaseRecord 租赁出库记录
     * @return 结果
     */
    @Override
    public int updateLeaseRecord(LeaseRecord leaseRecord)
    {
        return leaseRecordMapper.updateLeaseRecord(leaseRecord);
    }

    /**
     * 批量删除租赁出库记录
     * 
     * @param ids 需要删除的租赁出库记录主键
     * @return 结果
     */
    @Override
    public int deleteLeaseRecordByIds(String ids)
    {
        return leaseRecordMapper.deleteLeaseRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除租赁出库记录
     *
     * @param ids 需要软删除的租赁出库记录主键
     * @return 结果
     */
    @Override
    public int softDeleteLeaseRecordByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            LeaseRecord leaseRecord = leaseRecordMapper.selectLeaseRecordById(Long.valueOf(s));
            int i = leaseRecordMapper.update(null, Wrappers.<LeaseRecord>lambdaUpdate()
                    .set(LeaseRecord::getIsDelete, 1L)
                    .eq(LeaseRecord::getId, leaseRecord.getId()));
            count = count + i;
        }
        return count;
    }

    /**
     * 删除租赁出库记录信息
     * 
     * @param id 租赁出库记录主键
     * @return 结果
     */
    @Override
    public int deleteLeaseRecordById(Long id)
    {
        return leaseRecordMapper.deleteLeaseRecordById(id);
    }
}
